<html>
<head>
	<meta charset='utf-8' />
	<title>小区信息助手后台</title>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
	<style>
		@media screen and (max-width:450px){
			#content,.nav_div{width:98%;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		@media screen and (min-width:450px){
			#content,.nav_div{width:450px;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
	</style>
</head>
<body>
<div id='content' style='position:relative;border:0px solid'>
	<h1 style='text-align:center'>小区通知管理</h1>
	
	<div style='text-align:center;margin:20px 0;display:flex'>
		<select id="province" style='flex:1'>
			<option value="">吉林省</option>
		</select>
		<select id="city" style='flex:1'>
			<option value="">通化市</option>
		</select>
		<select id="county" style='flex:1'>
			<option value="">柳河县</option>
		</select>
	</div>

	<div style='margin:20px auto;text-align:center'>
		<label><input type="radio" name='stype' value='all'>全部</label>
		<label><input type="radio" name='stype' value='all'>待审</label>
		<label><input type="radio" name='stype' value='all'>未过</label>
		<label><input type="radio" name='stype' value='all'>正常</label>
	</div>


	<div id='msg_list'>
		<div style='border-bottom:1px solid #ccc'>
			<div style='display:flex;text-align:center;margin:5px'>
				<div style='flex:1;text-align:left'>
					关于XXX的通知
				</div>
				<div style='width:50px;font-size:12px;line-height:24px'>待审</div>
				<div style='width:80px'>
					<button>更改状态</button>
				</div>
			</div>
			<div style='padding:10px;word-break:break-all'>
				<div>
					aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
				</div>
				<div style='font-size:12px;text-align:right'>
					发布人：xxxx　时间：2019.06.12 12:23:34
				</div>
			</div>
		</div>
	</div>

	<div id='fpage' style='margin:50px auto;text-align:center'></div>

</div>

</body>
</html>
<script src='../public/jquery.js'></script>
<script src='../public/ViewOpenCity.js'></script>
<script src='../public/fun.js'></script>
<script>
if(!sessionStorage.after_con_msg_pnow){
	sessionStorage.after_con_msg_pnow = 1;
}

$(function(){
	//底部导航与显示页面
	$.ajax({
		url:'after_template_bottom_nav.html',
		success(res){
			$('body').append(res);
		}
	});

	GetAndViewOpenCity(province,city,county,function(){
		$('#province,#city,#county').change(function(){
			sessionStorage.after_con_msg_pnow = 1;
			C(333);
		});

		_getCityInfoList();
	},1,1);

});



//获取指定城市的所有小区信息列表
function _getCityInfoList(){                                                 
	var data = {
		type:'getCityInfoList',
		city_code:GetCurrentCitycode().code,
		db_host:GetCurrentCitycode().db_host,
		db_name:GetCurrentCitycode().db_name,
		pnow:sessionStorage.after_con_msg_pnow
	}
	AjaxAfter(data,function(res){
		if(!/^{.*}$/.test(res)){
			return;
		}
		var tmp = JSON.parse(res);
		sessionStorage.admin_token1 = tmp.token1;
		_parseData(tmp.data);

	});
}

function _parseData(data){
	var str = '';
	if(typeof(data) != 'object' || data.length < 1){

		var pnow = parseInt(sessionStorage.after_con_msg_pnow)-1;
		Fpage(pnow,pnow,function(p){
			sessionStorage.after_con_msg_pnow = p;
			_getCityInfoList();
		},1,1,'#fpage');
		return;
	}
	for(var i=0;i<data.length;i++){
		C(data[i]);
		var time = StampToYmd(parseInt(data[i].time)*1000);

		switch(data[i].stat){
			case '1':var stat_str = '待审';break;
			case '2':var stat_str = '未过';break;
			case '3':var stat_str = '正常';break;
		}

		str += "<div style='border-bottom:1px solid #ccc'><div style='display:flex;text-align:center;margin:5px'><div style='flex:1;text-align:left'>"+ data[i].info_title +"</div><div style='width:50px;font-size:12px;line-height:24px'>" +stat_str+ "</div><div style='width:80px'><button onclick=_changeMsgStat("+ data[i].id +","+ data[i].area_id +")>更改状态</button></div></div><div style='padding:10px;word-break:break-all'><div>"+ data[i].info_content +"</div><div style='font-size:12px;text-align:right'>发布人："+ data[i].openid +"　时间："+ time +"</div></div></div>";
	}

	$('#msg_list').html(str);

	var pnow = parseInt(sessionStorage.after_con_msg_pnow);
	Fpage(pnow,pnow+1,function(p){
		sessionStorage.after_con_msg_pnow = p;
		_getCityInfoList();
	},1,1,'#fpage');
}

//更改状态
function _changeMsgStat(msg_id,area_id){
	if(!confirm('确认操作？')){
		return;
	}
	var data = {
		type:'changeMsgStat',
		city_code:GetCurrentCitycode().code,
		db_host:GetCurrentCitycode().db_host,
		db_name:GetCurrentCitycode().db_name,
		msg_id:msg_id,
		area_id:area_id
	}
	AjaxAfter(data,function(res){
		if(!/^{.*}$/.test(res)){
			return;
		}
		var tmp = JSON.parse(res);
		sessionStorage.admin_token1 = tmp.token1;
		if(tmp.stat == 'ok'){
			A('操作成功！');
			location.reload();
		}else{
			A('操作失败！');
		}
	});
}

</script>